import { effect } from "./effect";

export const computed = (getter: Function) => {
    let _value = effect(getter, {
        scheduler: () => { _dirty = true }
    });
    let _dirty = true;
    let cacheValue
    class ComputedRefImpl {
        get value() {
            if (_dirty) {
                cacheValue = _value();
                _dirty = false;
                return cacheValue;
            }
            return _value();
        }
    }
    return new ComputedRefImpl();
}